--[[/**
-- * 
 * [0] 累积所受伤害 > 该万分比, 必定触发成功
 * [1] 如果该值 > 0  表示,当前生命低于该万分比, 直接触发成功
 *
 * 该buff触发成功之后就移除了
-- *
-- */]]

---@class BuffEffect504100 : BaseBuffEffect
BuffEffect504100 = ClientFight.CreateClass("BuffEffect504100", ClientFight.BaseBuffEffect)
local t = BuffEffect504100
t.BuffEffect504100 = "BuffEffect504100";
function t:add(fight, buff)
    ClientFight.BaseBuffEffect.add(self, fight, buff);
    local action = t:action(fight, buff, 0);
    if (action == IBuffEffect.REMOVE) then
        return IBuffEffect.REMOVE;
    end
    return IBuffEffect.SUCCESS_ATTRI_HAS_CHANGE;
end

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    local damage = parameters[1];
    local oldDamage = buff.effectParams[t.BuffEffect504100] or 0;
    damage = damage + oldDamage;
    buff.effectParams[t.BuffEffect504100] = damage;
    local l = Utils.calcRatio(FighterAttributeManager.getFightAttr(buff.target, FighterAttributeEnum.HP), buff.buffBean.f_BuffEffectValue[1]);
    if (l > damage) then
        if (buff.buffBean.f_BuffEffectValue[2] > 0) then
            local hpPer = Utils.calcRatio(FighterAttributeManager.getFightAttr(buff.target, FighterAttributeEnum.HP), buff.buffBean.f_BuffEffectValue[2]);
            if (hpPer <= buff.target.hp) then
                return IBuffEffect.FAIL;
            end
        else
            return IBuffEffect.FAIL;
        end
    end
    local logDamage = damage;
    SkillRoleMgr.savePathFile("[" .. fight.frame .. "][EFFECT]Fighter " .. buff.target.fighterId .. " Buff"
            .. buff.modelId .. " 触发, buff期间总累积伤害: " .. logDamage);
    ClientFight.BaseBuffEffect.action(self, fight, buff, ...);
    return IBuffEffect.REMOVE;

end

t.New()